# 作者: 宇
# 2025年02月25日10时17分42秒
import re

ret = re.match(".*","M")
print(ret.group())
ret = re.match("[A-Z][a-z]*","MnnM")
print(ret.group())
ret = re.match("[A-Z][a-z]*","Aabcdefq")
print(ret.group())

print("-"*70)
names = ["name1", "2_name", "__name__"]
for name in names:
    ret = re.match(r"[a-zA-Z_]\w*",name)
    if ret:
        print(f'{name}是合法遍历名')
    else:
        print(f'{name}不是合法变量名')

#匹配0-99
ret = re.match(r"[1-9]?[0-9]","7")
print(ret.group())
ret = re.match(r"[1-9]?\d","33")
print(ret.group())
ret = re.match(r"[1-9]?\d$","0")
print(ret.group())

ret = re.match("[a-zA-Z0-9_]{6}","12a3g45678")
print(ret.group())
ret = re.match("[a-zA-Z0-9_]{8,10}","1ad1211112")
print(ret.group())
email_list = ["xiaoWang@163.com", "xiaoWang@163.comheihei", ".com.xiaowang@qq.com"]
for email in email_list:
    ret=re.match(r'\w{5,20}@163.com$',email)
    if ret:
        print(f'{email}是合法遍历名')
    else:
        print(f'{email}不是合法变量名')

ret = re.match(r"([^-]+)-(\d+)","010-12345678")
if ret:
    print(ret.group(1))
    print(ret.group(2))


